import React, { Component } from 'react'
import { connect } from 'react-redux'
import { increment, decrement } from './actions' // 导入你的 action creators

class counter extends Component {
  render() {
    return (
      <div>
        <p> Count: {this.props.count} </p>{' '}
        <button onClick={this.props.increment}> Increment </button>{' '}
        <button onClick={this.props.decrement}> Decrement </button>{' '}
      </div>
    )
  }
}

const mapStateToProps = state => ({
  count: state.count
})

const mapDispatchToProps = {
  increment,
  decrement
}

export default connect(mapStateToProps, mapDispatchToProps)(counter)
